# -*- coding: UTF-8 -*-

import requests
import re
from src.common.readConfig import ReadConfig



global sms_readconfig
sms_readconfig = ReadConfig("prod")


# 由于统一认证安全方面考量限制，登录用户名手机号需要是：13058019302，才可以调用该方法使用
# 调用时需要传入对用环境的短信链接URL：get_smscode(xxx_readconfig.geturl("sms_url_xxx"))
def get_smscode(sms_url):
    r = requests.get (sms_url)
    # 获取短信内容
    sms_content = r.json ()["records"]
    # 正则匹配出验证码内容
    sms_code = re.findall (r"您的验证码是:(.+?),", str (sms_content))
    # 获取最新的验证码
    sms = sms_code[0]
    print (sms)
    return sms


# 由于生产短信文案不同所以需要调用不同方法
def get_smscode_prod(sms_url):
    r = requests.get (sms_url)
    # 获取短信内容
    sms_content = r.json ()["records"]
    # 正则匹配出验证码内容
    sms_code = re.findall (r"您的验证码是：(.+?)，", str (sms_content))
    # 获取最新的验证码
    sms = sms_code[0]
    print (sms)
    return sms

def shop_smscode_prod(sms_url):
    r = requests.get (sms_url)
    # 获取短信内容
    sms_content = r.json ()["records"]
    # 正则匹配出验证码内容
    sms_code = re.findall (r"您的验证码是:(.+?),", str (sms_content))
    # 获取最新的验证码
    sms = sms_code[0]
    print (sms)
    return sms



if __name__ == '__main__':
    pass
